/**
 * Project Name:alqsoft-ms
 * File Name:BaseInfoProxy.java
 * Package Name:com.alqsoft.interceptor
 * Date:2016年10月27日下午3:57:21
 * Copyright (c) 2016, chenzhou1025@126.com All Rights Reserved.
 *
*/

package com.alqsoft.interceptor;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * ClassName:BaseInfoProxy <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason:	 TODO ADD REASON. <br/>
 * Date:     2016年10月27日 下午3:57:21 <br/>
 * @author   张灿
 * @version  主要拦截的业务要写到这里
 * @since    JDK 1.8
 * @see 	 
 */
public abstract class BaseInfoHandler extends AbstractHandler implements InvocationHandler{
	
	private String name;
	
	public BaseInfoHandler(String name){
		this.name = name;
	}
	
	 // 目标对象   
    private Object target; 
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("输出了："+name);
		String content = (String)args[0];
		boolean r = filterContent(content);
        if(this.getHandler()!=null&&r==true){
        	return this.getHandler().invoke(proxy, method, args);
        }else{
        	Object result = method.invoke(target, args);
        	return result;
        }
	}

	public void setTarget(Object target) {
		this.target = target;
	}
}
